package cn.zhuo.knowledge.util.hutool.enums;

import cn.hutool.core.util.EnumUtil;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *
 * @author z2huo
 */
class EnumUtilTest {

    public static void main(String[] args) {
        List<String> names = EnumUtil.getNames(ComLevelEnum.class);
        names.forEach(System.out::println);
        System.out.println();

        System.out.println(EnumUtil.getFieldNames(ComLevelEnum.class));
        System.out.println();

        EnumUtil.getFieldValues(ComLevelEnum.class, "names").forEach(System.out::println);
        System.out.println();

        EnumUtil.getFieldValues(ComLevelEnum.class, "value").forEach(System.out::println);
        System.out.println();
        EnumUtil.getFieldValues(ComLevelEnum.class, "description").forEach(System.out::println);
        System.out.println();

        ComLevelEnum comLevelEnum = EnumUtil.getBy(ComLevelEnum::getValue, 5);
        System.out.println(comLevelEnum);
        comLevelEnum = EnumUtil.getBy(ComLevelEnum::getValue, 100);
        System.out.println(comLevelEnum);
        System.out.println();

        String desc = EnumUtil.getFieldBy(ComLevelEnum::getDescription, ComLevelEnum::getValue, 5);
        System.out.println(desc);
        System.out.println();

        LinkedHashMap<String, ComLevelEnum> enumMap = EnumUtil.getEnumMap(ComLevelEnum.class);
        System.out.println(enumMap);
        System.out.println(enumMap.get("CITY_COMPANY").getDescription());
        System.out.println();

        Map<String, Object> fieldMap = EnumUtil.getNameFieldMap(ComLevelEnum.class, "value");
        System.out.println(fieldMap);
        System.out.println(fieldMap.get("CITY_COMPANY"));
        System.out.println();

        System.out.println(EnumUtil.contains(ComLevelEnum.class, "CITY_COMPANY_HHH"));


    }

}
